#!/bin/sh
# - _cluster_ssh_key
# - _cluster_ssh_pub_key
# - _username

sed -i '/StrictHostKeyChecking/c StrictHostKeyChecking no' /etc/ssh/ssh_config

umask 0077
echo "$_cluster_ssh_key" > /root/.ssh/id_rsa
echo "$_cluster_ssh_pub_key" > /root/.ssh/id_rsa.pub
echo "$_cluster_ssh_pub_key" >> /root/.ssh/authorized_keys

[[ -n $_username ]] || exit 0
echo "$_cluster_ssh_key" > /home/$_username/.ssh/id_rsa
echo "$_cluster_ssh_pub_key" > /home/$_username/.ssh/id_rsa.pub
echo "$_cluster_ssh_pub_key" >> /home/$_username/.ssh/authorized_keys

chown -R $_username:$_username /home/$_username/.ssh
